package org.pulloid;

import java.io.InputStream;

import org.xmlpull.v1.XmlPullParserException;

public class CursorDef<T> {
	
	Class<T> cursorType;
	ElementContext<T> ctx;
	
	public CursorDef(Class<T> cursorType, ElementContext<T> ctx) {
		this.cursorType = cursorType;
		this.ctx = ctx;
	}
	
	public ElementContext<T> getContext() {
		return ctx;
	}
	
	public Cursor<T> pull(InputStream input) {
		try {
			return new Cursor<T>(cursorType, ctx, ParserFactory.newParser(), input);
		} catch (XmlPullParserException e) {
			throw new CursorException(e);
		}
	}

}
